package com.wuyi.tea.domain.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class R {
    
    private Integer code;
    private String message;
    private Object data;

    public final static Integer SUCCESS=1;  //成功
    public final static Integer FAIL=0;     //失败

    public static R success(){

        return R.builder()
                .code(SUCCESS)
                .message("操作成功")
                .data(null)
                .build();
    }

    public static R success(Object data){

        return R.builder()
                .code(SUCCESS)
                .message("操作成功")
                .data(data)
                .build();
    }

    public static R success(String message, Object data){

        return R.builder()
                .code(SUCCESS)
                .message(message)
                .data(data)
                .build();
    }

    public static R fail(){
        return R.builder()
                .code(FAIL)
                .message("操作失败")
                .data(null)
                .build();
    }

    public static R fail(String message){
        return R.builder()
                .code(FAIL)
                .message(message)
                .data(null)
                .build();
    }
    

}
